#pragma once

namespace MCCommon
{

class MCStatus;
class IPeerRecvListener;
class IPeerStatusListener;
class IPeer
{
    // The peer type.
    enum PeerType
    {
        // The net type peer.
        kPT_Net,

        // The com type peer.
        kPT_Com
    };    

    // The peer status. 
    enum PeerStatus
    {        
        // The peer is disconnected.
        kPS_DisConn,
    
        // The peer is connected.    
        kPS_Conn
    };

    /**
     * Destructor.
     * 
     */
    virtual ~IPeer(){}

    /**
     * Get peer type.
     * 
     */
    virtual PeerType GetPeerType() const = 0;

    /**
     * Get the status of this peer.
     * 
     */
    virtual PeerStatus GetPeerStatus() const = 0;

    /**
     * Start this peer.
     * 
     */
    virtual MCStatus Start() = 0;

    /**
     * Stop this peer.
     * 
     */
    virtual MCStatus Stop() = 0;

    /**
     * Send data to the connected peer.
     * 
     * @param pBuff    The buffer waiting to send.
     * @param lenBuff  The length of this buffer.
     * 
     * @return True if the data is sent successfully, otherwise false.
     */
    virtual bool Send
    (
        const char* pBuff,
        int lenBuff
    ) = 0;

    /**
     * Add a status listener.
     * 
     */
    virtual bool AddStatusListener
    (
        const IPeerStatusListener* pListener 
    ) = 0;
    
    /**
     * Remove a status listener.
     * 
     */
    virtual bool RemoveStatusListener
    (
        const IPeerStatusListener* pListener
    ) = 0;

    /**
     * Add a received data listener.
     * 
     */
    virtual bool AddRecvDataListener
    (
        const IPeerRecvListener* pListener
    ) = 0;

    /**
     * Remove a received data listener.
     * 
     */
    virtual bool RemoveRecvDataListener
    (
        const IPeerRecvListener* pListener
    ) = 0;
};

}